home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / pc / data / xxi_appendice_dvd.swf / scripts / __Packages / CAppendiceLemma.as < prev    next >
Text File  |  2007-11-08  |  7KB  |  220 lines

  1. class CAppendiceLemma extends Object
  2. {
  3.    function CAppendiceLemma(inBaseUrl, inProspBaseUrl)
  4.    {
  5.       super();
  6.       this.mBaseUrl = inBaseUrl;
  7.       this.mFrom = "";
  8.       this.mProspettiveBaseUrl = inProspBaseUrl;
  9.       this.Reset();
  10.    }
  11.    function NewLemma(id, tipo, titolo)
  12.    {
  13.       this.Reset();
  14.       this.mId = id;
  15.       this.mTipo = tipo;
  16.       this.mTitolo = StringUtils.HtmlFunction(titolo);
  17.       this.mChapterList = new Array();
  18.    }
  19.    function GetChapterLenght()
  20.    {
  21.       return this.mChapterList.length;
  22.    }
  23.    function HaveAbstract()
  24.    {
  25.       return this.mAbstract.length > 2;
  26.    }
  27.    function InitFromResult(inLemmaResult)
  28.    {
  29.       this.mInitialized = true;
  30.       if(inLemmaResult.id != this.mId)
  31.       {
  32.       }
  33.       this.mId = inLemmaResult.id;
  34.       this.mParagraphList = new Array();
  35.       this.mChapterList = new Array();
  36.       this.mMediaList = new Array();
  37.       this.mTitolo = StringUtils.HtmlFunction(inLemmaResult.titolo);
  38.       this.mParCount = inLemmaResult.parCount;
  39.       this.mAbstract = StringUtils.trimWhiteAndCr(inLemmaResult.abstract);
  40.       this.mAbstract = StringUtils.HtmlFunction(this.mAbstract);
  41.       var _loc5_ = undefined;
  42.       var _loc4_ = 0;
  43.       while(_loc4_ < inLemmaResult.indice.length)
  44.       {
  45.          var _loc10_ = inLemmaResult.indice[_loc4_];
  46.          var _loc3_ = new CAppendiceParagrafo(_loc10_);
  47.          if(_loc3_.mLevel == 0 && _loc3_.HaveText() || _loc3_.mLevel == 1)
  48.          {
  49.             _loc5_ = new Array();
  50.             this.mChapterList.push(_loc5_);
  51.          }
  52.          if(_loc5_)
  53.          {
  54.             _loc5_.push(_loc3_);
  55.          }
  56.          this.mParagraphList.push(_loc3_);
  57.          _loc4_ = _loc4_ + 1;
  58.       }
  59.       _loc4_ = 0;
  60.       while(_loc4_ < inLemmaResult.prospettive.length)
  61.       {
  62.          var _loc8_ = inLemmaResult.prospettive[_loc4_];
  63.          var _loc7_ = new CAppendiceProspettiva(this.mProspettiveBaseUrl);
  64.          _loc7_.InitFromResult(_loc8_);
  65.          this.mMediaList.push(_loc7_);
  66.          _loc4_ = _loc4_ + 1;
  67.       }
  68.       _loc4_ = 0;
  69.       while(_loc4_ < inLemmaResult.media.length)
  70.       {
  71.          var _loc9_ = inLemmaResult.media[_loc4_];
  72.          var _loc6_ = new CAppendiceContributo(this.mBaseUrl);
  73.          _loc6_.InitFromResult(_loc9_);
  74.          this.mMediaList.push(_loc6_);
  75.          _loc4_ = _loc4_ + 1;
  76.       }
  77.    }
  78.    function GetParagraph(inParNumber)
  79.    {
  80.       if(inParNumber >= 0 && inParNumber < this.mParagraphList.length)
  81.       {
  82.          return this.mParagraphList[inParNumber];
  83.       }
  84.    }
  85.    function GetParagraphById(inId)
  86.    {
  87.       var _loc3_ = null;
  88.       var _loc2_ = 0;
  89.       while(_loc2_ < this.mParagraphList.length)
  90.       {
  91.          if(this.mParagraphList[_loc2_].mId == inId)
  92.          {
  93.             _loc3_ = this.mParagraphList[_loc2_];
  94.             break;
  95.          }
  96.          _loc2_ = _loc2_ + 1;
  97.       }
  98.       return _loc3_;
  99.    }
  100.    function HaveIntroduction()
  101.    {
  102.       var _loc2_ = this.mChapterList[0];
  103.       var _loc3_ = _loc2_[0];
  104.       return _loc3_.mLevel == 0;
  105.    }
  106.    function GetChapterTitle(inChapterNum)
  107.    {
  108.       var _loc2_ = "";
  109.       var _loc4_ = this.mChapterList[inChapterNum];
  110.       var _loc3_ = _loc4_[0];
  111.       if(_loc3_.mLevel == 0)
  112.       {
  113.          _loc2_ = "";
  114.       }
  115.       else
  116.       {
  117.          _loc2_ = "<span class=\'s_title1\'>" + StringUtils.HtmlFunction(_loc3_.mTitolo) + "</span>";
  118.       }
  119.       return _loc2_;
  120.    }
  121.    function GetParagraphChapterNumber(inParId)
  122.    {
  123.       var _loc3_ = 0;
  124.       while(_loc3_ < this.mChapterList.length)
  125.       {
  126.          var _loc2_ = 0;
  127.          while(_loc2_ < this.mChapterList[_loc3_].length)
  128.          {
  129.             if(this.mChapterList[_loc3_][_loc2_].mId == inParId)
  130.             {
  131.                return _loc3_;
  132.             }
  133.             _loc2_ = _loc2_ + 1;
  134.          }
  135.          _loc3_ = _loc3_ + 1;
  136.       }
  137.       return 0;
  138.    }
  139.    function GetChapterText(inChapterNum)
  140.    {
  141.       var _loc7_ = this.mChapterList[inChapterNum];
  142.       var _loc8_ = _loc7_[0];
  143.       var _loc4_ = "<span class=\'s_content\'>";
  144.       if(_loc8_.mText.length > 0)
  145.       {
  146.          _loc4_ += "<span class=\'s_text0\'>" + StringUtils.HtmlFunction(_loc8_.mText) + "</span><br><br>";
  147.       }
  148.       var _loc3_ = 1;
  149.       while(_loc3_ < _loc7_.length)
  150.       {
  151.          var _loc2_ = _loc7_[_loc3_];
  152.          var _loc6_ = "<span class=\'s_title" + String(_loc2_.mLevel) + "\'>";
  153.          var _loc5_ = "<span class=\'s_text" + String(_loc2_.mLevel) + "\'>";
  154.          _loc4_ += _loc6_ + StringUtils.HtmlFunction(_loc2_.mTitolo) + "</span><br>";
  155.          _loc4_ += _loc5_ + StringUtils.HtmlFunction(_loc2_.mText) + "</span><br><br>";
  156.          _loc3_ = _loc3_ + 1;
  157.       }
  158.       _loc4_ += "</span>";
  159.       if(this.mId == 510 || this.mId == 285)
  160.       {
  161.          var _loc9_ = String.fromCharCode(9988);
  162.          if(_loc4_.indexOf(_loc9_) >= 0)
  163.          {
  164.             var _loc11_ = this.mId != 285 ? "A" : "B";
  165.             var _loc10_ = "<span class=\'s_Forbici\'>" + _loc11_ + "</span>";
  166.             _loc4_ = _loc4_.split(_loc9_).join(_loc10_);
  167.          }
  168.       }
  169.       return _loc4_;
  170.    }
  171.    function GetAbstractText()
  172.    {
  173.       var _loc2_ = "<span class=\'s_abstract\'>" + this.mAbstract + "</span>";
  174.       return _loc2_;
  175.    }
  176.    function GetAbstractTitle()
  177.    {
  178.       return "<span class=\'s_title1\'>Abstract</span>";
  179.    }
  180.    function GetIndiceTitle()
  181.    {
  182.       return "<span class=\'s_title1\'>Indice</span>";
  183.    }
  184.    function GetTitolo()
  185.    {
  186.       return "<span class=\'s_title0\'>" + this.mTitolo + "</span>";
  187.    }
  188.    function GetPreview()
  189.    {
  190.       var _loc2_ = "<span class=\'s_preview\'>";
  191.       _loc2_ += "<span class=\'s_title0\'>" + this.mTitolo + "</span><br><br>";
  192.       if(this.HaveAbstract())
  193.       {
  194.          _loc2_ += this.GetAbstractText();
  195.       }
  196.       else
  197.       {
  198.          var _loc3_ = this.GetChapterTitle(0);
  199.          var _loc4_ = this.GetChapterText(0);
  200.          if(_loc3_ != "")
  201.          {
  202.             _loc2_ += _loc3_ + "<br><br>";
  203.          }
  204.          _loc2_ += _loc4_;
  205.       }
  206.       _loc2_ += "</span>";
  207.       return _loc2_;
  208.    }
  209.    function Reset()
  210.    {
  211.       this.mId = "";
  212.       this.mParagraphList = new Array();
  213.       this.mMediaList = new Array();
  214.       this.mTitolo = "";
  215.       this.mParCount = 0;
  216.       this.mAbstract = "";
  217.       this.mInitialized = false;
  218.    }
  219. }
  220.